from pyftpdlib.authorizers import DummyAuthorizer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer


def main():
    # 创建用户授权管理器
    authorizer = DummyAuthorizer()
    # 添加用户权限
    authorizer.add_user("1", "1", "./", perm="elradfmw")
    authorizer.add_anonymous("d:/asm")

    # 初始化FTP处理程序
    handler = FTPHandler
    handler.authorizer = authorizer

    # 设置服务器
    server = FTPServer(("0.0.0.0", 21), handler)
    # 启动服务器
    server.serve_forever()


if __name__ == "__main__":
    main()
